export default {
    computed: {
        options() {
            return this.$store.state.tabStore["tabOptions"];
        },
        activeIndex: {
            get() {
                return this.$store.state.tabStore["activeIndex"];
            },
            set(val) {
                this.$store.commit('setActiveIndex', val);
            }
        }
    },
    methods: {
        onTabRouter() {
            let offsetTop = document.getElementById("elTabs");
            if(null === offsetTop){
                let innerHeight = window.innerHeight  - 160;
                this.$store.commit("setContainerHeight","height:"+innerHeight+"px");
            }else{
                let elementAside = window.innerHeight - offsetTop.offsetTop - 60;
                this.$store.commit("setContainerHeight","height:"+elementAside+"px");
            }
            let path = this.activeIndex;
            // 对应了二级路由，需要拼接添加第二级路由
            this.$router.push({path: path, query: {_k: randomString(7)}});//路由跳转
        },
        removeTab(targetName) {
            // //将改tab从options里移除
            this.$store.commit('deleteTabs', targetName);
            // //还同时需要处理一种情况当需要移除的页面为当前激活的页面时，将上一个tab页作为激活tab
            if (this.activeIndex === targetName) {
                if (this.options && this.options.length >= 1) {
                    this.$store.commit('setActiveIndex', this.options[this.options.length - 1].route);
                    this.$router.push({path: this.activeIndex, query: {_k: randomString(7)}});
                }
            }
        },
    }
};
